<!-- 
此组件初始化时不会自动加载数据，请在mounted中 this.$refs.[].initData()
如果放在dialog里面的吗，请在dialog的open事件中用this.$nextTick进行加载
 -->
<template>
  <div>
    <list id-key="id" ref="list" :disabled="disabled" :show-query="showQuery" show-checkbox
      :query-params="queryParams" :expand-query="expandQuery" page @get-data="onGetData" :data="data" :total="total"
      custom-get-data>
      <template #toolbar-left>
        <slot name="toolbar-left"></slot>
      </template>
      <template #query>
        <!-- <el-form-item label="ID">
          <el-input v-model.trim="queryParams.id" clearable></el-input>
        </el-form-item> -->
        <div>
          <el-form-item label="公司名称">
            <el-input v-model.trim="queryParams.companyName" placeholder="客户名称" clearable></el-input>
          </el-form-item>  
          <el-form-item label="客户名称">
            <el-input v-model.trim="queryParams.customerName" placeholder="客户名称" clearable></el-input>
          </el-form-item>  
        </div>       
      </template>
      <template #column>
        <el-table-column prop="companyName" width="200" label="公司名称">
          <template #default="{ row }">
            <span class="c-link" @click="openDetail(row.id)">{{ row.companyName || "无" }}</span><el-tag class="c-mg-l-5p" v-if="row.isDeleted" type="danger">删除</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="shortCode" width="100" align="center" label="简码">
        </el-table-column>
        <el-table-column prop="customerName" min-width="150" label="客户名称" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="businessClosingDate" width="120" label="商务关账日期" sortable="custom">
          <template v-slot="{ row }">
            <span>{{ row.accountingClosingDate | toDateString }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="chargingClosingDate" width="120" label="计费关账日期" sortable="custom">
          <template v-slot="{ row }">
            <span>{{ row.accountingClosingDate | toDateString }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="accountingClosingDate" width="120" label="会计关账日期" sortable="custom">
          <template v-slot="{ row }">
            <span>{{ row.accountingClosingDate | toDateString }}</span>
          </template>
        </el-table-column>        
        <el-table-column prop="creationTime" width="120" label="创建时间" sortable="custom">
          <template v-slot="{ row }">
            <span>{{ row.creationTime | toShortDatetimeString }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="lastModificationTime" width="120" label="最近修改时间" sortable="custom">
          <template v-slot="{ row }">
            <span>{{ row.lastModificationTime | toShortDatetimeString }}</span>
          </template>
        </el-table-column>
        <!-- slot[column] -->
        <slot name="column"></slot>
        <!--/ slot[column]-->
      </template>
    </list>
    <detail-dialog ref="detailDialog" />
  </div>
</template>
<script>
import listMixin from "@/mixins/list";
import list from "@/components/common/list";
import detailDialog from "./detailDialog";
import api from "@/api/pub/configure";
export default {
  mixins: [listMixin],
  components: {
    list,
    detailDialog
  },
  props: {},
  data() {
    return {
      //查询条件字段
      queryParams: {
        invoiceNo: "",
        invoiceCode: "",
        serialNo: "",
        buyerTitleName: "",
        sellerTitleName: "",
        statuses: [],
      },
      data: [],
      total: 0
    };
  },
  methods: {
    getStatusType(status) {
      var text = "";
      switch (status) {
        case 0:
          text = "info";
          break;
        case 1:
          text = "";
          break;
        case 2:
          //作废
          text = "info";
          break;
        case 3:
          //冲红
          text = "warning";
          break;
        case 6:
          text = "danger";
          break;
      }
      return text;
    },
    openInvoice(url) {
      window.open(url);
    },
    openDetail(id) {
      // this.$refs.detailDialog.openDetail(id);
    },
    onGetData(params) {
      this.$refs.list.loading(true);
      api.getPageList(params).then(res => {
        if (res.code != 0) {
          return;
        }
        this.data = res.data.list;
        this.total = res.data.total;
        this.$refs.list.loading(false);
      })
    },
    getCheckedRows() {
      return this.$refs.list.getCheckedRows();
    },
    reload() {
      this.$refs.list.reload();
    }
  },
};
</script>